using UnityEngine;
using System.Collections;

public class EnemyHealth : MonoBehaviour {
	public float health = 1;
	public Transform fireP;
	public Transform spinP;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		if(health<=0){
			int i = Random.Range(1,5);
			if(i == 1){
				int j = Random.Range(1,3);
				if(j == 1){
					Network.Instantiate(spinP, transform.position, transform.rotation,0);
				}
				if(j == 2){
					Network.Instantiate(fireP,transform.position,transform.rotation,0);
				}
			}
			GameObject.Destroy(gameObject);
		}
	
	}
	
	public void damage(float d){
		health -= d;
		networkView.RPC("updateHealth", RPCMode.Others, health);
	}
	[RPC]
	void updateHealth(float h){
		health = h;
	}
}
